package com.jadows.tdog.controller;

import com.jadows.tdog.base.R;
import com.jadows.tdog.service.TranslateService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CompletableFuture;

@RestController
@RequiredArgsConstructor
@RequestMapping("/translate")
public class TranslateController {

    final TranslateService translateService;

    @PostMapping
    public R<String> translate(String text) {
        CompletableFuture<String> completableFuture =
                translateService.asyncTranslate(text, "auto", "zh", null);
        return R.ok(completableFuture.join());
    }

}
